package WaiBao;

import java.util.Arrays;

public class WangYuXin {
    public static void main(String[] args) {
        String[] name = {"凯凯(班长)", "大大(团支书)", "小桥(学习委员)", "猪猪(体育委员)", "张嘿嘿", "曲兰", "何景明", "赵德刚", "赵乃", "嘟嘟", "赵东来", "韩与",
                "赵青青", "李凯", "王浩", "利好", "小龙女", "武铁", "吴刚", "李铁", "李刚", "王自力", "师进", "小郎", "马锦旗", "王朝阳", "雷富贵", "王才",
                "王大庆", "王宇欣(学生)"};//考生本人: 王宇欣(学生)
        int[] Age = {19, 20, 18, 19, 18, 21, 18, 21, 19, 19, 18, 18, 18, 20, 20, 19, 18, 18, 18, 18, 19, 19, 20, 20, 20, 18, 19, 19, 18, 19};
        double[] S1 = {88, 82, 84, 90, 68, 69, 78, 89, 80, 90, 90, 87, 85, 79, 65, 68, 69, 99, 96, 88, 92, 91, 95, 88, 75, 74, 78, 74, 80, 91};
        double[] S2 = {78, 85, 69, 66, 68, 67, 88, 79, 90, 90, 90, 77, 86, 75, 65, 65, 86, 79, 66, 68, 92, 71, 95, 85, 75, 84, 79, 64, 90, 92};
        double[] S3 = {78, 96, 80, 95, 79, 69, 78, 89, 80, 60, 93, 87, 85, 75, 65, 68, 69, 69, 96, 93, 92, 81, 95, 95, 79, 84, 77, 71, 89, 93};

        double sumS;//代表每个学生的总分
        double average;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            sumS = S1[i] + S2[i] +S3[i];
//           average = (sumS * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + sumS);
//            System.out.println(name[i] + "的平均分为:" +average);
//        }
//
        double Result = 0, Average = 0;
        double[] shuzu = new double[30];
//        for (int i = 0; i < 30; i++) {
//            Result = S1[i] + S2[i] + S3[i];
//            average = (Result * 1.0) / 3;
//            shuzu[i] = average;
//        }
//
//        for (int i = 0; i < shuzu.length - 1; i++) {
//            for (int j = 0; j < shuzu.length - i - 1; j++) {
//                if (shuzu[j] < shuzu[j + 1]) {
//                    double tep = shuzu[j];
//                    shuzu[j] = shuzu[j + 1];
//                    shuzu[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(shuzu[i]);
//        }


        double h1 = 0, h2 = 0, h3 = 0;//计算每门课的平均分
        double k1 = 0, k2 = 0, k3 = 0;//计算每门课标准差
        double m1 = 0, m2 = 0, m3 = 0;//计算每门课中位数
        double sum2 = 0;
        for (int i = 0; i < S1.length; i++) {
            sum2+=S1[i];
        }
        h1 = (sum2*1.0)/30;
        System.out.println("生物化学的班级平均分为:"+h1);
        double Sum = 0;
        for (int i = 0; i < S2.length; i++) {
            Sum+=S2[i];
        }
        h2 = (Sum*1.0)/30;
        System.out.println("微生物学的班级平均分为:"+h2);
        double sum = 0;
        for (int i = 0; i <S3.length; i++) {
            sum+=S3[i];
        }
        h3 = (sum*1.0)/30;
        System.out.println("人体组织解剖学的班级平均分为:"+h3);

        double c1 = 0,c2 = 0,c3 = 0;
        for (int i = 0; i < S1.length; i++) {
            c1+= (S1[i] - h1)*(S1[i] - h1);
        }
        k1 = Math.sqrt(c1*1.0/30);
        System.out.println("生物化学的班级标准差为:"+k1);

        for (int i = 0; i < S2.length; i++) {
            c2+= (S2[i] - h2)*(S2[i] - h2);
        }
        k2 = Math.sqrt(c2*1.0/30);
        System.out.println("微生物学的班级标准差为:"+k2);

        for (int i = 0; i < S3.length; i++) {
            c3+= (S3[i] - h3)*(S3[i] - h3);
        }
        k3 = Math.sqrt(c3*1.0/30);
        System.out.println("人体组织解剖学的班级标准差为:"+k3);

        Arrays.sort(S1);
        Arrays.sort(S2);
        Arrays.sort(S3);
        m1 =( S1[15]+S1[16])*1.0/2;
        m2 =( S2[15]+S2[16])*1.0/2;
        m3 =( S3[15]+S3[16])*1.0/2;
        System.out.println("生物化学的中位数为:"+m1);
        System.out.println("微生物学的中位数为:"+m2);
        System.out.println("人体组织解剖学的中位数为:"+m3);
    }
}
